import java.util.Arrays;
import java.util.Random;

/**
 * Test - 测试类
 */
public class Test {

  public static void main(String[] args) {
    // 创建账户
    Account a1 = new Account("a1", 1000.0);
    Account a2 = new Account("a2", 1000.0);
    // 创建银行
    Bank bank = new Bank(Arrays.asList(a1, a2));
    // 创建线程开始转账
    for (int i = 0; i < 10; i++) {
      Thread t = new Thread() {
        // 重写run方法
        @Override
        public void run() {
          Random random = new Random();
          double amount = random.nextDouble() * 100;
          // 处理double的精度
          bank.transfer(a1, a2, Math.round(amount * 100) / 100);
        }
      };
      t.start();
    }
  }
}